-
Notifications
You must be signed in to change notification settings - Fork 770
🚀 feat(model): add UniNet #2797
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
🚀 feat(model): add UniNet #2797
Conversation
Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>
Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>
Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>
Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>
Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>
Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love the implementation! Only few minor comments
Signed-off-by: Ashwin Vaidya <ashwin.vaidya@intel.com>
Signed-off-by: Ashwin Vaidya <ashwin.vaidya@intel.com>
Signed-off-by: Ashwin Vaidya <ashwin.vaidya@intel.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds the UniNet model implementation for anomaly detection to the anomalib library. UniNet is designed for diverse domains and supports both supervised and unsupervised anomaly detection with a focus on multi-class scenarios.
- Implements complete UniNet model architecture with teachers, student, and bottleneck modules
- Adds domain-related feature selection and attention bottleneck components
- Refactors ResNet decoder to be shared between Reverse Distillation and UniNet models
Reviewed Changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 6 comments.
Show a summary per file
File | Description |
---|---|
src/anomalib/models/image/uninet/ | Complete UniNet model implementation with PyTorch and Lightning modules |
src/anomalib/models/components/backbone/ | Refactored ResNet decoder to be shared across models |
src/anomalib/models/image/reverse_distillation/ | Updated imports to use shared decoder component |
examples/configs/model/uninet.yaml | Configuration file for UniNet model |
third-party-programs.txt | Added license attribution for UniNet |
Signed-off-by: Ashwin Vaidya <ashwin.vaidya@intel.com>
Signed-off-by: Ashwin Vaidya <ashwin.vaidya@intel.com>
Signed-off-by: Ashwin Vaidya <ashwin.vaidya@intel.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work. I have a few small comments
Decoder network implementation | ||
""" | ||
|
||
# Copyright (C) 2025 Intel Corporation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
copyright goes to the top?
Same for other files as well.
class AttentionBottleneck(nn.Module): | ||
"""Attention Bottleneck for UniNet.""" | ||
|
||
expansion: int = 4 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you rename expansion
to be a bit more specific or add a comment.
loss: nn.Module, | ||
) -> None: | ||
super().__init__() | ||
self.teachers = Teachers(teacher_backbone) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any advantage of creating the student and bottleneck in lightning model and the teachers in torch model ?
self.bce_loss = torch.nn.BCEWithLogitsLoss() | ||
# Used to post-process the student features from the de_resnet model to get the predictions | ||
self.avgpool = nn.AdaptiveAvgPool2d((1, 1)) | ||
self.fc = nn.Linear(256, 1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would this 256 in nn.Linear(256, 1) be valid for the set of possible backbones?
📝 Description
uninet.yaml
does not work as Early Stopping from config is broken for all the models.Results
Combined
Original
Anomalib
Anomaly Map Examples
✨ Changes
Select what type of change your PR is:
✅ Checklist
Before you submit your pull request, please make sure you have completed the following steps:
For more information about code review checklists, see the Code Review Checklist.